package com.example.springprinciple;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class BeanLifeComponent {
    private Cat cat;
    public BeanLifeComponent() {
        System.out.println("执⾏构造函数");
    }

    @Autowired
    public void setCat(Cat cat) {
        System.out.println("设置属性");
        this.cat = cat;
    }
    /**
     * 初始化
     */
    @PostConstruct
    public void postConstruct() {
        System.out.println("执⾏ PostConstruct()");
    }
    public void use() {
        System.out.println("执⾏了use⽅法");
    }
    /**
     * 销毁前执⾏⽅法
     */
    @PreDestroy
    public void preDestroy() {
        System.out.println("执⾏：preDestroy()");
    }
}
